package cn.dgut.training.vo;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;

import java.util.List;

@Data
public class BaseVO<T> {

    /**
     * 总记录数
     */
    private Integer total;

    /**
     * 总页数
     */
    private Integer pages;
    /**
     * 每页条数
     */
    private Integer size;
    /**
     * 当前页
     */
    private Integer current;

    /**
     * 返回集合
     */
    List<T> list;

    public BaseVO(IPage page) {

        this.total = ((Long)page.getTotal()).intValue();
        this.pages = ((Long)page.getPages()).intValue();
        this.size = ((Long)page.getSize()).intValue();
        this.current = ((Long)page.getCurrent()).intValue();
        this.list = page.getRecords();
    }

    public BaseVO() {

    }

}
